﻿
@{
    ViewBag.Title = "RevenueDetailesReport";
    Layout = "~/Views/Shared/_Index.cshtml";
}

<div class="rows">
    <div class="panel panel-default">
        <table class="form">
            <tr>
                <th class="formTitle">开始日期：</th>
                <td class="formValue">
                    <input id="kssj" type="text" class="form-control input-wdatepicker form-an"
                           onclick="WdatePicker({ dateFmt: 'yyyy-MM-dd'})" value="@(DateTime.Now.ToString("yyyy-MM-01"))" />
                </td>
                <th class="formTitle">结束日期：</th>
                <td class="formValue">
                    <input id="jssj" type="text" class="form-control input-wdatepicker form-an"
                           onclick="WdatePicker({ dateFmt: 'yyyy-MM-dd'})" value="@(DateTime.Now.ToString("yyyy-MM-dd"))" />
                </td>
                <th class="formTitle">治疗师：</th>
                <td class="formValue">
                    <select id="Therapist" class="form-control">
                        <option>==请选择==</option>
                    </select>
                </td>
                <td class="formValue" style="padding-left:20px;">
                    <input type="button" id="btn_search" onclick="submit();" class="btn btn-primary btn-md" value="查询" style="width:55px" />
                </td>
                <td></td>
            </tr>
        </table>
    </div>
</div>

<div class="ui-layout" id="layout" style="height:100%;width:100%;">
    <iframe class="ui-layout-center" style="width:100%;" id="iframerightiframerightiframerightttt" name="iframerightiframerightiframerightttt"
            scrolling="auto" allowtransparency="true" frameborder="0"></iframe>
</div>

<script type="text/javascript">

    var reportServerHOST = '@(ViewBag.ReportServerHOST)';
    var orgId = '@(ViewBag.OrgId)';
    var isHospAdministrator = '@(ViewBag.IsHospAdministrator)';
    var curUserCode = '@(ViewBag.CurUserCode)';
    var curUsergh = '@(ViewBag.curUsergh)';

    var uri = '/ReportServer/Pages/ReportViewer.aspx?%2fHIS.Report.1%2f%e6%9c%8d%e5%8a%a1%e4%bb%a3%e7%a0%81%e7%9b%88%e5%88%a9&rs:Command=Render';
    //var uri = '/ReportServer/Pages/ReportViewer.aspx?%2fHIS.Report.1%2f%e6%9c%8d%e5%8a%a1%e4%bb%a3%e7%a0%81%e7%9b%88%e5%88%a9&rs:Command=Render';

    function submit() {
        
        if (!$("#OrganizeId").val()) {
            $.modalAlert("请选择医疗机构", "warning");
            return;
        }
        if ($('#kssj').val().length == 0) {
            $.modalAlert("缺少开始时间", "error");
            return;
        }
        if ($('#jssj').val().length == 0) {
            $.modalAlert("缺少结束时间", "error");
            return;
        }
        if ($('#kssj').val() > $('#jssj').val()) {
            $.modalAlert("开始时间不能大于结束时间", "error");
            return;
        }
        var url = getUrl();

        url += "&kssj=" + $('#kssj').val();
        url += "&jssj=" + $('#jssj').val();
        url += "&Therapist=" + $('#Therapist').val();

        setTimeout("$.loading(true, '正在请求报表页面...');", 10);
        $("#iframerightiframerightiframerightttt").attr('src', url);
    }

    $("#iframerightiframerightiframerightttt").load(function () {
        $.loading(false);
    });

    $(function () {
        var h = $(window).height() - 55;
        $('#layout iframe').css('height', h);

    });

    function getUrl() {
        if (uri.StartWith('/')) {
            uri = uri.substr(1);
        }
        var srcUrl = uri;
        srcUrl = reportServerHOST + srcUrl;

        //GRS非管理查看下级机构所有治疗师数据
        if (isHospAdministrator == "false" && $("#OrganizeId").val() != orgId) {
            $("#Therapist").removeAttr("disabled").css("background-color", "white");
        }
        //获取自定义样式
        if (true) {
            if (srcUrl.indexOf('&rc:') == -1) {
                srcUrl += "&rc:Stylesheet=MyStyleSheet";
            }
        }

        if (true) {
            if (srcUrl.indexOf('&rs:') == -1) {
                srcUrl += "&rs:";
            }
            else {
                srcUrl += "&";
            }
            srcUrl += "orgId=";
            srcUrl += $("#OrganizeId").val();
        }

        if (false) {
            if (srcUrl.indexOf('&rs:') == -1) {
                srcUrl += "&rs:";
            }
            else {
                srcUrl += "&";
            }
            srcUrl += "curUserCode=";
            srcUrl += curUserCode;
        }

        if (false) {
            if (srcUrl.indexOf('&rs:') == -1) {
                srcUrl += "&rs:";
            }
            else {
                srcUrl += "&";
            }
            srcUrl += "isHospAdministrator=";
            srcUrl += isHospAdministrator;
        }

        return srcUrl;
    }

</script>

<script type="text/javascript">
    function funcOrganizeIdChange() {
        //治疗师
        $("#Therapist").bindSelect({
            url: "/Report/GetRehabDoctorList?orgId=" + $("#OrganizeId").val(),
            id: "StaffGh",
            text: "StaffName"
        });

        //机构非管理人员只能查看自己的治疗师数据
        if (isHospAdministrator == "false" && $("#OrganizeId").val() == orgId) {
            $("#Therapist").val(curUsergh).trigger("change").attr("disabled", "disabled").css("background-color", "rgb(241, 244, 246)");
        }

        submit();
    }
</script>
@Html.Partial("_ReportOrganizeIdDDLSearchView")
